package com.google.code.puertorico.actors

import scala.actors.Actor
import com.google.code.puertorico._
import adt.EndOfRound

object EndRoundActor extends Actor {
  def act() {
    loop {
      react {
        case ActionSequence(state, actions) => {
          val newGovernor = state.nextGovernor;
          var newState = state.copy(governor = newGovernor, activePlayer = newGovernor);

          // TODO: Each unused strategy card (i.e. the cards in "availableStrategyCards" should have their bonus increased by one.
          // TODO: A quick hack:
          newState = newState.copy(availableStrategyCards = List(Settler(0), Mayor(0), Builder(0), Craftsman(0), Trader(0), Captain(0), Prospector(0)))

          ChooseStrategyCardActor ! ActionSequence(newState, EndOfRound :: actions);

          // TODO: Is the game over? Check three end conditions

          // TODO: Decide when
          if (actions.size > 10) {
            AnalysisActor ! ActionSequence(state, actions);
          }

        }
      }
    }
  }
}